home *** CD-ROM | disk | FTP | other *** search
Gui4CLI script | 1998-07-06 | 14.6 KB | 638 lines |
- G4C
-
- ; $VER: FSearch.gc 1.1
- ; by D.Keletsekis 15/9/97
-
- ; GUI for the FSearch command
-
- ; You must have FSearch 1.1 in the guis:c/fsearch directory, or
- ; else change the paths given in the 2 Launch commands.
-
- ; This gui can be called as :
- ; GUILOAD guis:g4c/fsearch.gc SearchPath
-
- ; ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- ;
- ; Globals
- ;
- ; ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
-
- WINBIG 103 22 409 159 'FSearch 1.1 by D.Keletsekis'
- WinType 11110001
- varpath 'fsearch.ft/dir.gc'
- winout "kcon:0/100/690/170/FSearch Output/auto/close/wait"
- BOX 2 13 406 128 OUT button
-
-
- ; ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- ;
- ; System events
- ;
- ; ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
-
- xOnLoad
- setgad FSearch.gc 101 hide
- setgad FSearch.gc 201/250 hide
- setgad FSearch.gc 300/350 hide
- setgad FSearch.gc 325/333 off ; size
- setgad FSearch.gc 305/306 off ; date
- GuiOpen FSearch.gc
- ; the default values
- if $$ARG.0 > ''
- searchpath = $$ARG.0
- else
- searchpath = sys:
- endif
- file = '#?'
- subdirs = ALL
- findtxt = ''
- case = ''
- strsearch = On
- output = gui
- format = 'VERBOSE'
- nobin = ''
- nopath = ''
- details = ''
- highlight = HL
- min_size = ''
- max_size = ''
- from = ''
- to = ''
- header = ''
- update fsearch.gc 2 $searchpath
- setgad fsearch.gc 7 on
- ; load the file types
- lvuse fsearch.ft 1
- lvchange :fsearch.types
-
- xOnClose
- GuiQuit FSearch.gc
- GuiQuit fsearch.ft ; filetypes gui
- GuiQuit fsearch.rmb
-
- xONRMB
- if $guimode = RES
- guiopen fsearch.rmb
- endif
-
-
- ; ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- ;
- ; Gui Mode cycler
- ;
- ; ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
-
- ; ---- a cycler to change the gui to its various modes
-
- XCYCLER 2 0 186 13 "" guimode
- gadhelp 'Click to change the GUI mode - use "m" for shortcut'
- gadid 500
- gadkey m ; use 'm' to cycle it
- CStr "FSearch Parameters" PAR
- CStr "FSearch Settings" SET
- cstr "Date, Size & Type" DATE
- cstr "FSearch Results" RES
- gosub FSearch.gc guichange
-
- xroutine guichange
- docase $guimode
- case = PAR
- setgad FSearch.gc 1/13 show
- setgad FSearch.gc 21/24 show
- setgad FSearch.gc 101 hide
- setgad FSearch.gc 300/350 hide
- setgad FSearch.gc 201/250 hide
- break
- case = SET
- setgad FSearch.gc 1/13 hide
- setgad FSearch.gc 21/24 hide
- setgad FSearch.gc 101 hide
- setgad FSearch.gc 300/350 hide
- setgad FSearch.gc 201/250 show
- break
- case = DATE
- setgad FSearch.gc 1/13 hide
- setgad FSearch.gc 21/24 hide
- setgad FSearch.gc 101 hide
- setgad FSearch.gc 201/250 hide
- setgad FSearch.gc 300/350 show
- break
- case = RES
- setgad FSearch.gc 1/13 hide
- setgad FSearch.gc 21/24 hide
- setgad FSearch.gc 101 show
- setgad FSearch.gc 300/350 hide
- setgad FSearch.gc 201/250 hide
- break
- endcase
- ; redraw FSearch.gc
- ; NEW - using PARTREDRAW - looks great eh?
- partredraw FSearch.gc 4 15 402 124
-
- if $guimode != RES
- SetWintitle FSearch.gc 'FSearch by D. Keletsekis'
- endif
-
-
- ; ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- ;
- ; Parameters
- ;
- ; ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
-
- ; ------ choose searchpath(s)
-
- BOX 10 20 388 64 in button
- gadid 12
-
- CTEXT 20 25 "Search in :" #screen 8 2 0 0001
- gadid 1
-
- XTEXTIN 18 37 350 13 "" searchpath sys: 100
- gadhelp 'This is the path FSearch will start searching from'
- gadid 2
- setgad FSearch.gc 5 on ; set cursor to next textin gad
-
- XBUTTON 370 37 18 13 "<" ; choose a searchpath
- gadhelp 'Will pop-up a requester to let you choose a path'
- gadid 3
- ReqFile -1 -1 300 200 'Choose SearchPath:' DIR searchpath $searchpath
- update FSearch.gc 2 $searchpath
-
- ; ---- filename pattern
-
- CTEXT 21 54 "File name pattern :" #screen 8 2 0 0001
- gadid 4
-
- XTEXTIN 17 65 371 13 "" file '#?' 100
- gadhelp 'Enter the filepattern wanted - #? means all files'
- gadid 5
- setgad FSearch.gc 7 on ; set cursor to next textin gad
-
- XCHECKBOX 364 24 25 9 "_Include sub-directories" subdirs ALL "" ON
- gadhelp 'Check ON to make FSearch recurse through all subdirectories'
- gadid 11
-
- ; ---- text search
-
- CTEXT 22 99 "Find text :" #screen 8 2 0 0001
- gadid 6
-
- XTEXTIN 17 111 371 13 "" findtxt '' 100
- gadhelp 'Enter the text you want to find - or nothing for no text search.'
- gadid 7
-
- BOX 9 92 389 37 IN BUTTON
- gadid 8
-
- XCHECKBOX 360 97 25 9 "Case sensitive" case CS "" OFF
- gadhelp 'Check ON to make the search Case Sensitive'
- gadid 9
-
-
- ; ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- ;
- ; Search results listview
- ;
- ; ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
-
- XLISTVIEW 4 15 400 124 "" resfile "" 10 MULTI
- gadhelp "Display search results - Click RMB to save list contents"
- gadid 101
- gadfont #mono 8 001
-
- ; deal with file - if running with dir.gc
- ifexists gui dir.gc
- ; check the first characters
-
- ; use popup window to deal with choice, if it's a file
-
- if $resfile[0][4] = '32m'
- cutvar resfile[4] cut word 1 resfile
- cutvar resfile cut char -4 temp ; cut the csi
- ifexists file $resfile
- guiload guis:tools/rtn/FilePop \"$fsearch.gc/resfile\"
- endif
-
- ; or it could be a file but with highlight off
-
- elseif $resfile[0][1] != ' '
- and $resfile[0][1] != ''
- ifexists file $resfile
- guiload guis:tools/rtn/FilePop \"$fsearch.gc/resfile\"
- endif
-
- ; then it must be a line number.. I use CEd as an editor
-
- elseifexists port rexx_ced
- cutvar resfile[4] cut word 1 resfile
- sendrexx rexx_ced 'jump to line $resfile'
- endif
-
- endif
-
-
-
- ; ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- ;
- ; FSearch settings
- ;
- ; ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
-
- ; ------- output mode
-
- BOX 23 28 175 71 in button
- gadid 201
-
- XRADIO 156 38 18 9 output 2
- gadhelp 'Choose where you want the output from FSearch to go to'
- gadid 202
- rstr 'Output to Gui' gui
- RStr 'Output to Shell' cli
-
- ; ----------- Output format
-
- XRADIO 156 68 19 9 format 2
- gadhelp 'Says it all really..'
- gadid 203
- RStr 'Show text found' 'VERBOSE'
- RStr 'Filenames only' ''
-
- ; ------------ Settings - checkboxes
-
- BOX 214 28 176 70 IN BUTTON
- gadid 208
-
- XCHECKBOX 350 35 25 9 'Highlight results' highlight "HL" "" ON
- gadhelp 'Bask in the glory of colored ansi text - (OS V39)'
- gadid 205
-
- XCHECKBOX 350 50 25 9 "Check binary files" nobin "" "NOBIN" ON
- gadhelp 'Check ON to make FSearch search binary files'
- gadid 211
-
- XCHECKBOX 350 65 25 9 "Show File Path" nopath "" "NOPATH" ON
- gadhelp 'Will output filenames using their full path'
- gadid 212
-
- XCHECKBOX 350 79 25 9 "Show File Details" details "INFO" "" OFF
- gadhelp 'Will also print out file size, date etc'
- gadid 213
-
- ; ------- help & save settings
-
- XBUTTON 299 119 91 13 "Help.."
- gadhelp 'Loads the FSearch.doc - the full Gui4Cli installation is needed'
- *FILENAME = '$$win.path\fsearch.readme'
- guiload guis:tools/read.gc
- guiopen read.gc
- gadid 220
-
-
-
- ; ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- ;
- ; DO IT!
- ;
- ; ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
-
- ; This is where the commandline is formed and launched. The name of
- ; the variable which holds it is 'options'
-
-
- XBUTTON 20 143 91 13 "_Search"
- gadhelp 'Start the search!'
- gadid 501
- if $searchpath < ' '
- setwintitle FSearch.gc 'Wrong parameters!'
- stop
- endif
- SetWintitle FSearch.gc Searching...
-
- ; --- construct the command line
-
- options = '$searchpath '
- if $file != '#?'
- and $file > ' '
- appvar options 'PAT=$file '
- endif
- if $findtxt > ' '
- appvar options 'TXT=\"$findtxt\" $case '
- endif
- if $size = SIZE
- if $min_size > ' '
- and $min_size > 0
- min = $min_size
- if $min_type = mb
- min == $min * 1000
- endif
- appvar options 'MIN=$min '
- endif
- if $max_size > ' '
- and $max_size > 0
- max = $max_size
- if $max_type = mb
- max == $max * 1000
- endif
- appvar options 'MAX=$max '
- endif
- if $min_size > $max_size
- and $max_size != ''
- ezreq 'Minimum size is more than\nMaximum size..' Ooops! ''
- stop
- endif
- endif
- if $date = DATED
- if $from_date > ' '
- appvar options 'FROM=$from_date '
- endif
- if $to_date > ' '
- appvar options 'TO=$to_date '
- endif
- endif
- extract header clean header
- if $header > ' '
- and $header != NONE
- appvar options 'HEADER=$header'
- appvar options '#? '
- endif
- appvar options '$format $nobin $nopath $details $highlight $subdirs'
-
- ; disable gadgets
- setgad FSearch.gc 501/502 off
-
- ; --- launch according to where it should output
-
- if $output = cli
- say '\n-------------- Search results :\n'
- launch 1 'guis:c/FSearch $options'
- say 'guis:c/FSearch $options\n'
- else
- launch 2 'guis:c/FSearch >pipe:findres $options'
- ; say 'guis:c/FSearch >pipe:findres $options\n'
- update FSearch.gc 500 3 ; change gui to show results listview
- guimode = RES
- gosub FSearch.gc guichange
- endif
-
- ; ---------- xONRETURN commands - handle returns according to launches
-
- ; -- return from shell launch
-
- xonreturn 1 ; to the shell
- say '-------------- Search finished.\n'
- setgad FSearch.gc 501/502 on
- SetWintitle FSearch.gc 'Search finished.'
-
- ; -- return from gui output mode launch
-
- xonreturn 2 ; to gui or file
- lvuse FSearch.gc 101
- setgad FSearch.gc 501/502 on
- SetWintitle FSearch.gc 'Search finished.'
-
- ; -- the pipe event where the output is piped at
-
- xpipe pipe:findres ON
- gadid 999
- lvuse FSearch.gc 101 ; whenever a line is available
- lvadd $$pipe ; append it to our listv
-
- ; -- We're all human..
-
- xonfail
- setwintitle FSearch.gc '** Error **'
- setgad FSearch.gc 501/502 on
-
-
- ; ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- ;
- ; Clear & cancel buttons
- ;
- ; ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
-
- ; --------------- The CLEAR button - reset all settings
-
- XBUTTON 205 143 91 13 "C_lear"
- gadhelp 'Clear the current gadgets - will not change hidden gadgets'
- gadid 502
- docase $guimode
- case = PAR
- file = #?
- update FSearch.gc 5 $file
- findtxt = ''
- update FSearch.gc 7 ''
- break
- case = SET
- break
- case = DATE
- date = ANY
- update FSearch.gc 301 0
- from_date = ''
- update FSearch.gc 305 ''
- to_date = ''
- update FSearch.gc 306 ''
- size = ANY
- update FSearch.gc 321 0
- min_size = ''
- update FSearch.gc 325 ''
- max_size = ''
- update FSearch.gc 330 ''
- min_type = kb
- update FSearch.gc 329 0
- max_type = kb
- update FSearch.gc 333 0
- setgad FSearch.gc 325/333 off ; size
- setgad FSearch.gc 305/306 off ; date
- header = NONE
- update FSearch.gc 341 'All files'
- break
- case = RES
- lvuse FSearch.gc 101 ; clear the lv
- lvclear
- break
- endcase
-
- ; --------------- The CANCEL button
-
- XBUTTON 300 143 91 13 "_Cancel"
- gadhelp 'Abort the Search!'
- gadid 503
- breaktask guis:c/FSearch C ; break fsearch
- setgad FSearch.gc 999 CLEAN ; stop & flush pipe output
- lvuse FSearch.gc 101
- lvadd "**** BREAK ****"
-
-
- ; ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- ;
- ; SET DATE, SIZE & TYPE
- ;
- ; ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
-
- ; The surrounding boxes
- BOX 13 17 381 47 in button
- gadid 335
- BOX 13 74 381 41 in button
- gadid 336
-
- ; ----- Date
-
- CTEXT 20 20 Date #screen 8 2 0 "0001"
- gadid 300
-
- XRADIO 171 25 17 9 date 4
- gadid 301
- RStr 'Any date' ANY
- RStr 'Files dated' DATED
- if $date = ANY
- setgad FSearch.gc 305/306 off
- else
- setgad FSearch.gc 305/306 on
- endif
-
- XTEXTIN 298 31 77 12 "From:" from_date '' 100
- gadid 305
- setgad FSearch.gc 306 on
- XTEXTIN 298 45 77 12 "To:" to_date '' 100
- gadid 306
- setgad FSearch.gc 305 on
-
- ; ----- Size
-
- CTEXT 20 77 Size #screen 8 2 0 "0001"
- gadid 320
-
- XRADIO 173 82 18 9 size 4
- gadid 321
- RStr 'Any size' ANY
- RStr 'Files sized' SIZE
- if $size = SIZE
- setgad FSearch.gc 325/333 on
- else
- setgad FSearch.gc 325/333 off
- endif
-
- XTEXTIN 247 85 47 12 Over min_size "" 100
- gadid 325
- XBUTTON 296 85 15 12 "<"
- gadid 327
- if $min_size > 0
- counter min_size dec 1
- update FSearch.gc 325 $min_size
- endif
- XBUTTON 312 85 15 12 ">"
- gadid 328
- counter min_size inc 1
- update FSearch.gc 325 $min_size
- XCYCLER 328 85 52 12 "" min_type
- CStr Kb kb
- CStr Mb mb
- gadid 329
-
- XTEXTIN 247 99 46 12 Under max_size "" 100
- gadid 330
- XBUTTON 296 99 15 12 "<"
- gadid 331
- if $max_size > 0
- counter max_size dec 1
- update FSearch.gc 330 $max_size
- endif
- XBUTTON 312 99 15 12 ">"
- gadid 332
- counter max_size inc 1
- update FSearch.gc 330 $max_size
- XCYCLER 328 99 52 12 "" max_type
- CStr Kb kb
- CStr Mb mb
- gadid 333
-
- ; ----- File type
-
- CTEXT 28 122 Type #screen 8 2 0 0001
- gadid 340
- TEXT 66 122 289 12 "All files" 80 BOX
- gadid 341
- XBUTTON 357 122 23 12 "<"
- gadid 342
- guiopen fsearch.ft
-
- ; ##################################################################
- ; ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- ;
- ; FSearch.ft
- ;
- ; Gui with listview for choosing file header type
- ;
- ; ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- ; ##################################################################
-
- NEWFILE fsearch.ft
-
- WINBIG 245 109 179 116 ''
- WinType 00001000
- winonmouse 100 50
- varpath FSearch.gc
-
- xoninactive
- guiclose fsearch.ft
-
- xonrmb
- guiclose fsearch.ft
-
- ; start off with empty listview - load the fsearch.types file in the
- ; fsearch.gc xonload event
-
- XLISTVIEW 0 0 179 116 "" ftype '' 10 TXT
- gadid 1
- gadfont #mono 8 000
- guiclose fsearch.ft
- cutvar ftype cut word -1 header
- update FSearch.gc 341 $ftype
-
-
- ; ##################################################################
- ; ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- ;
- ; FSearch.rmb
- ;
- ; popup gui for RMB when in list results mode
- ;
- ; ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- ; ##################################################################
-
- NEWFILE fsearch.rmb
-
- WinBig 0 0 80 30 ""
- WinType 00001000
- winonmouse 30 6
-
- xOnRMB
- guiclose fsearch.rmb
-
- xOnInactive
- guiclose fsearch.rmb
-
- ;=============================== Save files list
-
- xbutton 0 0 0 15 "Save.."
- gadhelp 'Save output as..'
- guiclose fsearch.rmb
- choice = ''
- ReqFile -1 -1 300 200 "Save output as:" SAVE file $fsearch.gc/searchpath
- if $file > ' '
- guiwindow fsearch.gc wait
- lvuse fsearch.gc 101
- lvsave $file
- guiwindow fsearch.gc resume
- endif
-
- ;=============================== copy files
-
- xbutton 0 15 0 15 Cancel
- guiclose fsearch.rmb
-
- ; should add copy/move/delete for files in the list..
-
-
-